// Programming_Scala/src/ch03/while-script.scala
// WARNING:  This script runs for a LOOONG time!

import java.util.Calendar

def isFridayThirteen( cal: Calendar ): Boolean = {
  val dayOfWeek = cal.get( Calendar.DAY_OF_WEEK )
  val dayOfMonth = cal.get( Calendar.DAY_OF_MONTH )

  // Scala returns the result of the last expression in a method
  ( dayOfWeek == Calendar.FRIDAY ) && ( dayOfMonth == 13 )
}

while ( !isFridayThirteen( Calendar.getInstance() ) ) {
  println( "Today isn't Friday the 13th. Lame." )
  // sleep for a day
  Thread.sleep( 86400000 )
}

